<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>

    <title>上传测试</title>
  </head>
  <body>
    <div id="app">
      {{asd}}
      <input type="file" @change="upload" />
      <!-- <button @click="upload">上传</button> -->
    </div>

    <script>
      new Vue({
        data() {
          return {
            asd: 123
          };
        },
        methods: {
          upload(e) {
            const file = e.target.files[0];
            let formData = new FormData();
            formData.append('file', file);

            axios.post('/upload', formData).then(function (response) {
              console.log(response);
            });
          }
        }
      }).$mount('#app');
    </script>
  </body>
</html>
